#!/usr/bin/env python
# Problem Set 1 
# Name: Noah Spahn 
# Collaborators: none 
# Time: 5:30 hours

import math

def prime(num):
    """Determine if a given number is prime"""
    if num<9:
        #print 'less than 9'
        for x in range (2, num):
            #print num, 'in range'
            if num%x==0:
                #print 'inner test'
                return 1
    ##sqrt is the highest number to test, int will round down, so we add one to level it off
    for x in range (2, int(math.sqrt(num))+1): 
    #print '...::testing...', num,'sqrt::', math.sqrt(num)
        if num%x == 0:  # if remainder is 0, the number is not prime
            return 1
        
list = []
for val in range(2, 10000): #---Generate range of numbers
    #print 'looping through', val 
    pr = prime(val)
    if pr != 1:   # if returned value is 1, the number isn't prime
        list.append(val); #canidate is prime, add it to the list
    #print val
    if len(list) == 1000:
        print val
        break

###  RESOURCES ###
#http://www.julialyon.com/primes/3.html
#http://code.activestate.com/recipes/366178/
#http://www.gidforums.com/t-9440.html

# Prime Factorization
#http://blog.dhananjaynene.com/2009/01/2009-is-not-a-prime-number-a-python-program-to-compute-factors/

# Python variable types: 
#http://www.tutorialspoint.com/python/python_variable_types.htm